package com.augurit.gzcgwsp.ywcmn.convert;

import java.util.ArrayList;
import java.util.List;

import org.dozer.DozerBeanMapper;
import com.augurit.gzcgwsp.ywcmn.entity.YwComQyxxTwo;
import com.augurit.gzcgwsp.ywcmn.web.form.YwComQyxxTwoForm;

public class YwComQyxxTwoConvertor {
	public static YwComQyxxTwoForm convertVoToForm(YwComQyxxTwo entity) {
		if (entity == null) return null;
		
		return new DozerBeanMapper().map(entity, YwComQyxxTwoForm.class);
	}
	
	public static void convertFormToVo(YwComQyxxTwoForm form, YwComQyxxTwo entity) {
		
		if(form.getId() != null)
			entity.setId(form.getId());
		if(form.getAddressTwo() != null && form.getAddressTwo().trim().length() > 0)
			entity.setAddressTwo(form.getAddressTwo());
		if(form.getSqdwTwo() != null && form.getSqdwTwo().trim().length() > 0)
			entity.setSqdwTwo(form.getSqdwTwo());
		if(form.getAqfzrTwo() != null && form.getAqfzrTwo().trim().length() > 0)
			entity.setAqfzrTwo(form.getAqfzrTwo());
		if(form.getPhoneTwo() != null && form.getPhoneTwo().trim().length() > 0)
			entity.setPhoneTwo(form.getPhoneTwo());
		if(form.getTelTwo() != null && form.getTelTwo().trim().length() > 0)
			entity.setTelTwo(form.getTelTwo());		
		if(form.getLxrTwo() != null && form.getLxrTwo().trim().length() > 0)
			entity.setLxrTwo(form.getLxrTwo());	
		if(form.getXmjlTwo() != null && form.getXmjlTwo().trim().length() > 0)
			entity.setXmjlTwo(form.getXmjlTwo());	
		if(form.getXmjlTelTwo() != null && form.getXmjlTelTwo().trim().length() > 0)
			entity.setXmjlTelTwo(form.getXmjlTelTwo());	
		if(form.getTemplateCodeTwo() != null && form.getTemplateCodeTwo().trim().length() > 0)
			entity.setTemplateCodeTwo(form.getTemplateCodeTwo());
		if(form.getSqrqTwo() != null)
			entity.setSqrqTwo(form.getSqrqTwo());
		if(form.getUpdateDateTwo() != null)
			entity.setUpdateDateTwo(form.getUpdateDateTwo());
		
	}
	
	public static List<YwComQyxxTwoForm> convertVoListToFormList(List<YwComQyxxTwo> ywComQyxxTwoList) {
		if(ywComQyxxTwoList != null && ywComQyxxTwoList.size() > 0) {
			List<YwComQyxxTwoForm> ywComQyxxTwoFormList = new ArrayList<YwComQyxxTwoForm>();
			for(int i=0; i<ywComQyxxTwoList.size(); i++) {
				ywComQyxxTwoFormList.add(convertVoToForm(ywComQyxxTwoList.get(i)));
			}
			return ywComQyxxTwoFormList;
		}
		return null;
	}
	
	public static List<YwComQyxxTwo> convertFormListToVoList(List<YwComQyxxTwoForm> ywComQyxxTwoFormList) {
		if(ywComQyxxTwoFormList != null && ywComQyxxTwoFormList.size() > 0) {
			List<YwComQyxxTwo> ywComQyxxTwoList = new ArrayList<YwComQyxxTwo>();
			for(int i=0; i<ywComQyxxTwoFormList.size(); i++) {
				YwComQyxxTwo ywComQyxxTwo = new YwComQyxxTwo();
				convertFormToVo(ywComQyxxTwoFormList.get(i), ywComQyxxTwo);
				ywComQyxxTwoList.add(ywComQyxxTwo);
			}
			return ywComQyxxTwoList;
		}
		return null;
	}
}